import { defineStore } from 'pinia';
import { LangEnum } from '@/enums/styleEnum';
import { StorageEnum  } from '@/enums/storageEnum';
import { setLocalStorage } from '@/utils';

export const useLangStore = defineStore('langStore', () => {
  // 语言
  const lang = ref(LangEnum.ZH);

  // 设置语言
  const setLang = (value: LangEnum): void => {
    lang.value = value;
    setLocalStorage(StorageEnum.GO_LANG_STORE, value);
    window.location.reload();
  };

  return {
    lang,
    setLang,
  };
})